package com.example.sharding.common;



import lombok.Data;

@Data
public class ICCResult<T>{

    public ICCResult() {
    }

    public ICCResult(boolean success, String code, String msg, T data) {
        this.success = success;
        this.code = code;
        this.errMsg = msg;
        this.data = data;
    }

    private Boolean success;

    private String code;

    private String errMsg;

    private T data;


    public static <T> ICCResult<T> success(T t, String msg) {
        return new ICCResult<>(true,ICCErrorCode.SUCCESS.getCode(), msg, t);
    }

    public static ICCResult success() {
        return new ICCResult<>(true,ICCErrorCode.SUCCESS.getCode(), ICCErrorCode.SUCCESS.getMsg(), null);
    }

    public static <T> ICCResult<T> success(T t) {
        return success(t, ICCErrorCode.SUCCESS.getMsg());
    }

    public static <T> ICCResult<T> fail(String code, String msg) {
        return new ICCResult<>(false,code, msg, null);
    }

    public static <T> ICCResult<T> fail(ICCErrorCode errorCode) {
        return fail(errorCode.getCode(), errorCode.getMsg());
    }



    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
